Shader "ShaderDemo/Chapter 5/Chapter-FalseColor"
{
    Properties
    {
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 pos : SV_POSITION;
                float4 color:COLOR0;  
            };


            v2f vert (appdata_full v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);

                //可视化法线方向
                //o.color = fixed4(v.normal*0.5+fixed3(0.5,0.5,0.5),1.0);
                
                //可视化切线
                //o.color = fixed4(v.tangent*0.5+fixed3(0.5,0.5,0.5),1.0);

                //可视化副切线防线
                //fixed3 binormal = cross(v.normal,v.tangent.xyz)*v.tangent.w;
                //o.color = fixed4(binormal*0.5+fixed3(0.5,0.5,0.5),1.0);

                //可视化第一组纹理坐标
                //o.color = fixed4(v.texcoord.xy,0.0,1.0);

                //可视化第二组纹理坐标
                //o.color = fixed4(v.texcoord1.xy,0.0,1.0);

                //可视化第一组纹理坐标的小数部分
                //o.color = frac(v.texcoord);
                //if(any(saturate(v.texcoord)-v.texcoord))
                //{
                //    o.color.b = 0.5;
                //}
                //o.color.a = 1.0;

                //可视化第二组纹理坐标的小数部分
                //o.color = frac(v.texcoord);
                //if(any(saturate(v.texcoord)-v.texcoord))
                //{
                //    o.color.b = 0.5;
                //}
                //o.color.a = 1.0;

                //可视化顶点颜色
                //o.color = v.color;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                return i.color;
            }
            ENDCG
        }
    }
}
